﻿@using NCprod.Models;
@{
    Layout = null;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Left</title>
    <script src="../../Scripts/prototype.lite.js" type="text/javascript"></script>
    <script src="../../Scripts/moo.fx.js" type="text/javascript"></script>
    <script src="../../Scripts/moo.fx.pack.js" type="text/javascript"></script>
    <style type="text/css">
        * {
            margin: 0px;
            padding: 0px;
        }

        .tabal {
            border-collapse: collapse;
        }

            .tabal td {
                border: 1px #f00 solid;
            }

        img {
            border: none;
        }

        body {
            font: 12px Arial, Helvetica, sans-serif;
            color: #000;
            background-color: #EEF2FB;
            margin: 0px;
        }

        #container {
            width: 182px;
        }

        H1 {
            font-size: 12px;
            margin: 0px;
            width: 182px;
            cursor: pointer;
            height: 30px;
            line-height: 20px;
        }

            H1 a {
                display: block;
                width: 182px;
                color: #000;
                height: 30px;
                text-decoration: none;
                moz-outline-style: none;
                background-image: url(../../PIC/menu_bgs.png);
                background-repeat: no-repeat;
                line-height: 30px;
                text-align: center;
                margin: 0px;
                padding: 0px;
            }

        .content {
            width: 182px;
            height: 26px;
        }

        .MM ul {
            list-style-type: none;
            margin: 0px;
            padding: 0px;
            display: block;
        }

        .MM li {
            font-family: Arial, Helvetica, sans-serif;
            font-size: 12px;
            line-height: 26px;
            color: #333333;
            list-style-type: none;
            display: block;
            text-decoration: none;
            height: 26px;
            width: 182px;
            padding-left: 0px;
        }

        .MM {
            width: 182px;
            margin: 0px;
            padding: 0px;
            left: 0px;
            top: 0px;
            right: 0px;
            bottom: 0px;
            clip: rect(0px,0px,0px,0px);
        }

            .MM a:link {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 12px;
                line-height: 26px;
                color: #333333;
                background-image: url(../../PIC/menu_bg1.png);
                background-repeat: no-repeat;
                height: 26px;
                width: 182px;
                display: block;
                text-align: center;
                margin: 0px;
                padding: 0px;
                overflow: hidden;
                text-decoration: none;
            }

            .MM a:visited {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 12px;
                line-height: 26px;
                color: #333333;
                background-image: url(../../PIC/menu_bg1.png);
                background-repeat: no-repeat;
                display: block;
                text-align: center;
                margin: 0px;
                padding: 0px;
                height: 26px;
                width: 182px;
                text-decoration: none;
            }

            .MM a:active {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 12px;
                line-height: 26px;
                color: #333333;
                background-image: url(../../PIC/menu_bg1.png);
                background-repeat: no-repeat;
                height: 26px;
                width: 182px;
                display: block;
                text-align: center;
                margin: 0px;
                padding: 0px;
                overflow: hidden;
                text-decoration: none;
            }

            .MM a:hover {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 12px;
                line-height: 26px;
                font-weight: bold;
                color: #e74c3c;
                background-image: url(../../PIC/menu_bg2.png);
                background-repeat: no-repeat;
                text-align: center;
                display: block;
                margin: 0px;
                padding: 0px;
                height: 26px;
                width: 182px;
                text-decoration: none;
            }
    </style>
    <script type="text/javascript">
    </script>
</head>
<body>

    <table width="100%" style="height: 280px;" border="0" cellpadding="0" cellspacing="0"
           bgcolor="#EEF2FB">
        <tr>
            <td width="182" valign="top">
                @{
                    if (SystemParam.CurrentUser != null)
                    {
                        var db = new NCtecanEntities();

                        decimal userid = SystemParam.CurrentUser.userid;
                        
                        decimal rid=0,rid1=0;
                        
                        if(db.sys_user_role.FirstOrDefault(s => s.userid == userid)!=null)
                            
                        { rid1 = db.sys_user_role.FirstOrDefault(s => s.userid == userid).rid;}
                        
                        rid = rid1;
                        
                        var root = (from e in db.sys_role_function
                                    join o in db.sys_function on e.fid equals o.fid
                                    where e.rid == rid && o.pid == 0
                                    select new
                                    {
                                        o.fid,
                                        o.function,
                                        o.order
                                    }).Distinct().OrderBy(ob => ob.order);
                        <div id="container">
                            @foreach (var p in root)
                            {
                                <h1 class="type">
                                    <a href="javascript:void(0)">@(p.function)</a>
                                </h1>
                                <div class="content">
                                    <table cellpadding="0" cellspacing="0" style="height: 5px;">
                                        <tr>
                                            <td>
                                                <img alt="" src="../../PIC/menu_topline.png" width="182px" height="2px" />
                                            </td>
                                        </tr>
                                    </table>
                                    <ul class="MM">
                                        @{
                                var chid = from e in db.sys_role_function
                                           join o in db.sys_function on e.fid equals o.fid
                                           where e.rid == rid && o.pid == p.fid
                                           select o;
                                        }
                                        @foreach (var c in chid.OrderBy(o => o.order))
                                        {
                                            <li><a href='@(string.Format("/{0}/{1}", c.control, c.functionname))' target="main">@(c.function)</a></li>
                                        }
                                    </ul>
                                </div>
                            }
                        </div>
                    }
                }
                <script type="text/javascript">
                    var contents = document.getElementsByClassName('content');
                    var toggles = document.getElementsByClassName('type');

                    var myAccordion = new fx.Accordion(
		toggles, contents, { opacity: true, duration: 400 }
	);
                    myAccordion.showThisHideOpen(contents[0]);
                </script>
            </td>
        </tr>
    </table>
</body>
</html>
